package com.mit.entity

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.mit.constants.HTTP_OK
import com.mit.constants.ResultMsg

/**
 * @author Lin
 * @date 2019/10/11
 * @function 请求结果格式
 * @Description
 */
sealed class BaseRespResult(
    open val code: Int,
    open val message: String,
    open val data: Any? = null
)

data class RespResult(
    override val code: Int,
    override val message: String,
    override val data: Any? = null
) : BaseRespResult(code, message, data)

data class FindResult(
    override val data: Any? = null,
    override val code: Int = HTTP_OK,
    override val message: String = ResultMsg.FIND_SUCCESS
) : BaseRespResult(code, message, data)

data class DeleteResult(
    override val data: Any? = null,
    override val code: Int = HTTP_OK,
    override val message: String = ResultMsg.DELETE_SUCCESS
) : BaseRespResult(code, message, data)

data class InsertResult(
    override val data: Any? = null,
    override val code: Int = HTTP_OK,
    override val message: String = ResultMsg.INSERT_SUCCESS
) : BaseRespResult(HTTP_OK, message, data)

data class UpdateResult(
    override val data: Any? = null,
    override val code: Int = HTTP_OK,
    override val message: String = ResultMsg.UPDATE_SUCCESS
): BaseRespResult(code, message, data)

/*@JsonIgnoreProperties("pageData")
data class PageResult<T : Any>(
    val pageData: IPage<T>,
    override val data: PageEntity<T> = PageEntity(
        pageData.records,
        pageData.size,
        pageData.current,
        pageData.total,
        pageData.pages
    ),
    override val code: Int = HTTP_OK,
    override val message: String = ResultMsg.FIND_SUCCESS
) : BaseRespResult(code, message, data)*/
